﻿<%@ Page Language="C#" Title ="修改昵称" AutoEventWireup="true" CodeBehind="ChangeUserName.aspx.cs" Inherits="chatblog.usercate.dialog.ChangeUserName" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <style   type ="text/css" >
        .inputText
        {
            width :180px;
        }       
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div style =" width :400px; height:300px;">
        <table>
            <tr>
                <td style=" text-align :right; width :150px ">
                    您的好友：
                </td>
                <td>
                    <span id="FriendIdSpan"></span>
                </td>
            </tr>
            <tr>
                <td style=" text-align :right; width :150px ">
                    原来的昵称：
                </td>
                <td>
                    <input type ="text" class ="inputText"  id="OriginFriendNameInput" readonly ="true"/>
                </td>
            </tr>
            <tr>
                <td style=" text-align :right ">
                    修改后的昵称：
                </td>
                <td>
                    <input  type ="text" class ="inputText" id="NewFriendNameInput" value=""/>
                </td>
            </tr>
            <tr>
                <td style =" text-align:right ">
                    <input  type ="button"  value="保存"  onclick ="renameUserName();"/>
                </td>
                <td style =" text-align:left "> 
                    <input  type ="button"  value="取消"  onclick="window.close();"/>
                </td>
            </tr>
        </table>
        <input  type ="hidden" id="GroupIdhidden"/>
    </div>  
    <script src="common.js" type="text/javascript"></script>
    <script type ="text/javascript" >
        function windowonload() {
            if (window.location.search == "") {
                alert("对不起，没有相应的参数！");
                closeWithNoTip();
            }
            else {
                var userid = getQueryString("userid");
                var groupid = getQueryString("groupid");
                var username = getQueryString("username");
                if (userid == null || userid == "" || groupid == "" || groupid == null) {
                    alert("对不起，您传递的参数不正确！");
                    closeWithNoTip();
                }
                paramsAllready = true;
                document.getElementById("FriendIdSpan").innerHTML = userid;
                document.getElementById("OriginFriendNameInput").value = username;
                document.getElementById("GroupIdhidden").value = groupid;
            }
        }
        window.onload = windowonload;
        //修改好友昵称
        function renameUserName() {
            if (paramsAllready == true && window.opener !=null) {
                var userid = getQueryString("userid");
                var groupid = getQueryString("groupid");
                var newUserName = document.getElementById("NewFriendNameInput").value;
                if (newUserName.replace(/\s/g, "") != "") {
                    var result = chatblog.usercate.chRoom.RenameGroupUserName(userid, groupid, newUserName);
                    if (result.value == true) {
                        window.opener.RefreshGroupDiv();
                        window.close(); 
                    }
                }
                else {
                    alert("对不起，新昵称不能为空！");
                }
            }
        }
    </script>
    </form>
</body>
</html>
